package fnv

const (
	_FNV_PRIME_32 uint32 = 16777619 // 16777619
	_FNV_PRIME_64 uint64 = 1099511628211
	
	_FNV_OFFSET_32 uint32 = 2166136261 // 2166136261(
	_FNV_OFFSET_64 uint64 = 14695981039346656037
)

// GenerateFNV32aHash 生成单次 FNV_1a 32位哈希值
func GenerateFNV32aHash(data []byte) uint64 {
	hash := _FNV_OFFSET_32
	for _, b := range data {
		hash ^= uint32(b)
		hash *= _FNV_PRIME_32
	}

	return uint64(hash)
}

// GenerateFNV64aHash 生成单次 FNV_1a 64位哈希值
func GenerateFNV64aHash(data []byte) uint64 {
	hash := _FNV_OFFSET_64
	for _, b := range data {
		hash ^= uint64(b)
		hash *= _FNV_PRIME_64
	}

	return hash
}
